package cn.lg.soar.redis.serializer;

import cn.lg.soar.common.util.data.DataUtil;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.SerializationException;

/**
 * @author luguoxiang
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
public class LongRedisSerializer implements RedisSerializer<Long> {

    @Override
    public byte[] serialize(Long value) throws SerializationException {
        return value == null ? null : DataUtil.longToBytes(value);
    }

    @Override
    public Long deserialize(byte[] bytes) throws SerializationException {
        return bytes == null ? null : DataUtil.byteToLong(bytes);
    }

}
